import VueRouter from 'vue-router'
import Vue from 'vue'

import Layout from '@/layout'
import Login from '@/views/login/index'
import Dashboard from '@/views/dashboard'
import agriMonitoring from '@/views/agriMonitoring'
import farmsStock from '@/views/farmsStock'

Vue.use(VueRouter)

const routes = [
  {
    path: '/shuzhongtian/login',
    component: Login,
    name: '/shuzhongtianlogin'
  },
  {
    path: '/shuzhongtian/mapH5',
    component: () => import('@/views/mapH5')
  },
  {
    path: '/shuzhongtian',
    component: Layout,
    redirect: '/shuzhongtian/dashboard',
    name: 'dashboard',
    children: [
      {
        path: '/shuzhongtian/agriLand',
        component: () => import('@/views/agriLand'),
        name: '地块'
      },
      {
        path: '/shuzhongtian/agriLandDetail',
        component: () => import('@/views/agriLandDetail'),
        name: '地块详情'
      },
      {
        path: '/shuzhongtian/agriMissionAdd',
        component: () => import('@/views/agriMissionAdd'),
        name: '添加农事'
      },
      {
        path: '/shuzhongtian/addLoilReport',
        component: () => import('@/views/addLoilreport'),
        name: '土壤改良'
      },
      {
        path: '/shuzhongtian/agriRole',
        component: () => import('@/views/agriRole'),
        name: '人员管理'
      },
      {
        path: '/shuzhongtian/agriRoleAdd',
        component: () => import('@/views/agriRoleAdd'),
        name: '用户新增'
      },
      {
        path: '/shuzhongtian/dashboard',
        component: Dashboard,
        name: '首页'
      },
      {
        path: '/shuzhongtian/agriMissionsEdit',
        component: () => import('@/views/agriLandDetail'),
        name: '地块详情编辑'
      },
      {
        path: '/shuzhongtian/agriMonitoring',
        component: agriMonitoring,
        name: '农情感知'
      },
      {
        path: '/shuzhongtian/userInfo',
        component: () => import('@/views/userInfo'),
        name: '用户信息'
      },
      {
        path: '/shuzhongtian/baseInfo',
        component: () => import('@/views/baseInfo'),
        name: '农场信息'
      },

      {
        path: '/shuzhongtian/agriMissionList',
        component: () => import('@/views/agriMissionList'),
        name: '农事记录'
      },
      {
        path: '/shuzhongtian/agriMonitoringDevice',
        component: () => import('@/views/agriMonitoringDevice'),
        name: '农情数据'
      },
      {
        path: '/shuzhongtian/agriMonitoringVideo',
        component: () => import('@/views/agriMonitoringVideo'),
        name: '视频监控'
      },
      {
        path: '/shuzhongtian/farmsStock',
        component: farmsStock,
        name: '农资出入库'
      },
      {
        path: '/shuzhongtian/farmsStockAdd',
        component: () => import('@/views/farmsStockAdd'),
        name: '农资入库'
      },
      {
        path: '/shuzhongtian/farmsStockStatistics/:pageId',
        component: () => import('@/views/farmsStockStatistics'),
        name: '农资统计记录'
      },
      {
        path: '/shuzhongtian/agriAreaAdd',
        component: () => import('@/views/mapAdd'),
        name: '地块添加'
      },
      {
        path: '/shuzhongtian/devicePictures',
        component: () => import('@/views/devicePiuture'),
        name: '图片展示'
      }
    ]
  }

]

const router = new VueRouter({ mode: 'history', routes })
// 获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
// 修改原型对象中的push方法
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router
